Conversation
| } | ||
|
|
||
| void createNewTask(Plan plan, [String description]) { | ||
| void createNewTask(Plan plan, [String? description]) { |
There was a problem hiding this comment.
If I leave it as String description, then I have a conflict on controller.createNewTask(plan); in _buildAddTaskButton function because we are not sending description in there, so that's I made this to be optional. However, I think there might be better way to handle this.
| class Plan { | ||
| final int id; | ||
| String name = ''; | ||
| String name; |
There was a problem hiding this comment.
I thought this assignment might be redundant as we are assigning it in the constructor on line 9.
| : id = model.id, | ||
| name = model?.data['name'], | ||
| tasks = model?.data['task'] | ||
| name = model.data['name'] ?? '', |
There was a problem hiding this comment.
I was getting type 'Null' is not a subtype of type 'String', so I decided to solve this way.
815a779 to
1287964
Compare
|
|
||
| static PlanController of(BuildContext context) { | ||
| PlanProvider provider = context.dependOnInheritedWidgetOfExactType<PlanProvider>(); | ||
| final provider = context.dependOnInheritedWidgetOfExactType<PlanProvider>() |
There was a problem hiding this comment.
If I specify PlanProvider, I get an error A value of type 'PlanProvider?' can't be assigned to a variable of type 'PlanProvider'.
96bc8bc to
d133e67
Compare
| } | ||
|
|
||
| void addTask(Plan plan, String description) { | ||
| final id = plan.tasks.last?.id ?? 0 + 1; |
There was a problem hiding this comment.
Initially, I had this conflict The receiver can't be null, so the null-aware operator '?.' is unnecessary.. However, if I remove ?. before id, then I get The left operand can't be null, so the right operand is never executed.. After that, the suggested looks like this final id = plan.tasks.last.id;. However, it breaks my code, so I actually came up with below code.
There was a problem hiding this comment.
have you found any solution to this issue?
There was a problem hiding this comment.
@amkfat lines 31 to 34 are the solution I came up with
fcc658b to
fd9f5a2
Compare
fd9f5a2 to
94aa2d6
Compare
No description provided.